package com.wzy.intercept;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.wzy.entity.User;

import java.util.Map;

public class AuthInterceptor extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {

        Map<String, Object> session=invocation.getInvocationContext().getSession();

        User user=(User)session.get("CURRENT_USER");

        if(user==null){
            return Action.LOGIN;
        }else{
            return invocation.invoke();
        }
    }
}
